<template>
  <el-config-provider :locale="lang">
    <div>
      <!-- 路由出口 路由匹配到的组件将渲染在这里 -->
      <router-view></router-view>
    </div>
  </el-config-provider>
</template>
<script setup lang="ts">
import { onMounted, watch, ref, computed } from "vue";
import { useConfig } from "@/store/config";
import iconfontInit from "@/utils/iconfont";
import { useI18n } from "vue-i18n";
import { useRoute } from "vue-router";
import zhCn from "element-plus/es/locale/lang/zh-cn"; //中文
import En from "element-plus/es/locale/lang/en";
const route = useRoute();
const config = useConfig();

// 初始化 element 的语言包
// const { getLocaleMessage } = useI18n();
//判断当前默认语言

const lang = ref(zhCn);

const getLocaleLang = () => {
  if (config.lang.defaultLang === "zh-cn") {
    lang.value = zhCn;
  } else {
    lang.value = En;
  }
};
/**
 * watch监听对象写法
 * 参数1：监听的参数
 * 参数2：监听的回调函数
 * 参数3：监听的配置（immediate）
 * watch(()=>{})
 */
onMounted(() => {
  //加载图标cdn链接
  iconfontInit();
  getLocaleLang();
});
</script>
<style lang="scss" scoped>
* {
  box-sizing: border-box;
}

html,
body,
#app {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  font-family: Helvetica Neue, Helvetica, PingFang SC, Hiragino Sans GB,
    Microsoft YaHei, SimSun, sans-serif;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  // background-color: #f5f5f5;
  font-size: 14px;
  overflow: hidden;
  position: relative;
}
</style>
